package edu.suda.xsap.controller;

import edu.suda.xsap.dto.CourseDto;
import edu.suda.xsap.service.CourseService;
import edu.suda.xsapadminutils.common.Result;
import edu.suda.xsapadminvo.CourseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {
    @Autowired
    private CourseService courseService;

    @PostMapping("/save")
    public Result save(@RequestBody CourseVO courseVO) {
        return courseService.save(courseVO);
    }

    @PostMapping("/delete")
    public Result delete(@RequestBody CourseVO courseVO) {
        return courseService.delete(courseVO);
    }

    @PostMapping("/update")
    public Result update(@RequestBody CourseVO courseVO) {
        return courseService.update(courseVO);
    }

    @GetMapping("/findAll")
    public List<CourseDto> findAll() {
        return courseService.findAll();
    }

}
